/**
 * 泛娱区块链 - WebPage
 * http://menger.me
 * @大梦
 */

'use strict';

import React from "react";
import {StyleSheet, WebView} from "react-native";
import Container from "../../component/common/Container";
import NavigationBar from "../../component/navigation/NavigationBar";
import SpinnerLoading from "../../component/common/SpinnerLoading";

class WebPage extends React.PureComponent {

    constructor(props) {
        super(props);
        this.state = {
            ready: false,
        }
    }

    componentDidMount() {

    }

    onLoadEnd = () => {
        // console.log('onLoadEnd---->', 'onLoadEnd');
        this.setState({ready: true});
    };

    render() {
        let {title, uri} = this.props.navigation.state.params;
        let {ready} = this.state;
        return (
            <Container>
                <NavigationBar title={title}/>
                <WebView
                    style={styles.webView}
                    onLoadEnd={this.onLoadEnd}
                    source={{uri}}
                />
                <SpinnerLoading isVisible={!ready}/>
            </Container>
        );
    }
}

const styles = StyleSheet.create({
    webView: {
        flex: 1,
    }
});

export default WebPage